﻿using HlELock.Core.Events;
using Prism.Mvvm;
using System.Windows;

namespace HlELock.Page.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private Visibility _visibleTiitle = Visibility.Collapsed;
        public Visibility VisibleTiitle
        {
            get { return _visibleTiitle; }
            set { SetProperty(ref _visibleTiitle, value); }
        }
        public MainWindowViewModel()
        {
            EventBus.Instace.GetEvent<MainWindowEvent>().Subscribe(obj =>
            {
                if (obj.TitleIsShow.HasValue)
                {
                    VisibleTiitle = obj.TitleIsShow.Value ? Visibility.Visible : Visibility.Collapsed;
                }
                if (!string.IsNullOrWhiteSpace(obj.UserName))
                {
                    UserName = obj.UserName;
                }
                if (obj.DeviceActive.HasValue)
                {
                    DeviceActive = obj.DeviceActive.Value;
                }
            });
        }

        private bool _deviceActive;
        public bool DeviceActive
        {
            get { return _deviceActive; }
            set { SetProperty(ref _deviceActive, value); }
        }

        private string _userName;
        public string UserName
        {
            get { return _userName; }
            set { SetProperty(ref _userName, value); }
        }

        private string _title = "深圳市鸿研电子技术开发有限公司";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }
    }

}
